<template>
	<view class="navBottom">
		<view class="navBottomList">
			<view class="Collection" @click="ganxingqu" v-if="collect!=1 && isColl == 0">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/star.svg"></image><view>感兴趣</view>
			</view>
			<view class="Collection" v-if="collect==1 || isColl==1" @click="noganxingqu">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/star-filled.svg"></image><view>取消</view>
			</view>
			<view class="share">
				<button class="sharec" type="default" open-type="share">
					<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/jump.svg"></image>
					<text style="line-height: 33rpx; font-size: 28rpx; margin-top: 10rpx;">分享</text>
				</button>
			</view>
			
			<view class="tel" v-if="isTel==1" @click="Calltel">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/tel.png"></image>
				<view>打电话</view>
			</view>
			<view class="tel" :class="isTel==2?'notCell':''" v-if="isTel==2" @click="telSend()">
				<view>下午14:00-18:00<view>可联系</view></view>
			</view>
			
			<view class="bauinessCard" v-if="isPublish==1 || isCard==1" @click="goMessage();">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/chat.svg"></image>
				<view>聊一聊</view>
			</view>
			<view class="bauinessCard" v-if="isPublish!=1 && isCard==0" @click="fractionCli()">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/mingpian.png"></image>
				<view>递名片</view>
			</view>
		</view>
		
		
		<u-popup :show="telTips" :round="10" bgColor="transparent" :overlay="false"
		customStyle="background:rgba(0,0,0,0.7); color:#fff;" mode="center" @close="close" @open="open">
			<view class="telTips">
				<image src="http://xgr.oss-cn-hangzhou.aliyuncs.com/icon/images/swap1.png"></image>
				<view>当前招工方休息</view>
				<view>请在{{timestr}}拨打电话联系</view>
			</view>
		</u-popup>
	</view>
</template>
<script>
import Index from "@/common/index-model.js"	
let index = new Index()
export default {
  props: {
    value: {
      typeof: Number,
      default: 0,
    },
    orderObj: {
		typeof: Object,
		default:null
	},
	isPublish:{
		typeof:String,
		default:''
	},
	//是否收藏
	collect: {
		typeof:Number,
		default:0
	}
  },
  data() {
    return {
		isCard: 0,
		isColl: this.collect===1?1:0,
		isTel: 1,
		telTips:false,
		timestr:''
	};
  },
  onLoad() {
  },
  
  onShow() {
  	var date = new Date();
	 let hh = today.getHours()
	 if(hh>=14 && hh<=18){
		 this.isTel = 1
	 }else{
		 this.isTel =2
	 }
  },
  methods: {
		change() {
			index.show_tips('请点击右上角分享给好友')
			return false
		},
		close() {
			this.telTips = false
		},
		open() {
			this.telTips = true
		},
		telSend(){
			this.$parent.showtelTips();
		},
		//递交名片
		fractionCli(){
			if(this.orderObj.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能给自己递交名片');return false;
			}
			let send={
				"targetId":this.orderObj.userId
			}
			index.getPublicUserMember('','/client/card/getCardPublishStatus','get',res=>{
				if(res.data.code == 200 && res.data.result==0){
					index.show_tips('您的名片暂无发布，请完善您的名片')
					return false
				}else if(res.data.code == 500){
					index.show_tips('系统错误')
					return false
				}else{
					index.getPublicUserMember(send,'client/public/add/contact','post',res=>{
						if(res.data.code == 200 && res.data.success){
							this.goMessage();
						}else{
							index.show_tips(res.data.message)
							return false
						}
					})
				}
			})			
		},
		goMessage(){
			if(this.orderObj.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能跟自己聊天');return false;
			}
			let url;
			if(this.isPublish){
				url='/pagesB/hxIm/index?user='+this.orderObj.hxName;
			}else{
				url='/pagesB/hxIm/index?user='+this.orderObj.hxName+'&userid='+uni.getStorageSync('userid')+"&type=mp";
			}
			index.navigate_to(url)
		},
		ganxingqu() {
			if(this.orderObj.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能收藏自己的好活');return false;
			}
			//console.log(this.orderObj,'====this.orderObj===')
			let url="client/job/add/collect/"+this.orderObj.orderId
			index.getPublicUserMember({},url,'post',res=>{
				console.log(res,'====xingqu')
				if(res.data.code == 200 && res.data.success){
					index.show_tips('收藏成功')
					//this.collect =1
                   // this.isColl = 2
				    this.isColl = 1
				}else{
					//this.isColl = 1
					if(res.data.code == '100007' && res.data.success == false){
						index.show_tips(res.data.message)
						this.isColl = 1
						return false
					}else{
						this.isColl = 0
						if(res.data.code == '401'){
							uni.removeStorageSync('token')
							setTimeout(()=>{
								index.navigate_to('/pagesC/login/login');
							},300)
							return false	
						}
						index.show_tips(res.data.message)
						return false
					}
				}
			})
		},
		noganxingqu() {
			let url="client/job/del/collect/"+this.orderObj.orderId;
			index.getPublicUserMember({},url,'post',res=>{
				console.log(res,'====xingqu')
				if(res.data.code == 200 && res.data.success){
					index.show_tips('取消收藏成功')
			        this.isColl = 0
					//this.collect=0
				}else{
					//this.isColl = 2
					if(res.data.code == '100007' && res.data.success == false){
						this.isColl = 1
						//this.collect=1
						index.show_tips(res.data.message)
						return false
					}else{
						index.show_tips(res.data.message)
						return false
					}
				}
			})
		},
		Calltel() {
			if(this.orderObj.hxName==uni.getStorageSync('hxuser')){
				index.show_tips('您不能给自己拨打电话');
				return false;
			}
			
			if(this.orderObj.appTimeSections && this.orderObj.appTimeSections.length>0){
				this.timestr = ''
				for(let i=0;i<this.orderObj.appTimeSections.length;i++){
					if(i == (this.orderObj.appTimeSections.length-1)){
						this.timestr += this.orderObj.appTimeSections[i].name
					}else{
						this.timestr += this.orderObj.appTimeSections[i].name +','
					}
				}
			}
			if(this.orderObj.orderId){
				console.log('打电话打电话===================================',this.orderObj)
				if(!uni.getStorageSync('token')){
				    let url="../../pagesC/login/login?urladd=jobinfo&id="+this.oid
				    index.navigate_to(url)
				    return false
				   }
				uni.makePhoneCall({
					phoneNumber: this.orderObj.phone
					// phoneNumber: res.data.result
				});
				// index.getPublicUserMember({"orderId":this.orderObj.orderId},'secret/call/secretNumber','post',res=>{
				// 	console.log('打电话打电话===================================',res)
				// 	if(res.data.code == 200 && res.data.success){
				// 		uni.makePhoneCall({
				// 			phoneNumber: self.orderObj.phone
				// 			// phoneNumber: res.data.result
				// 		});
				// 	}else if(res.data.code == 100017){
				// 		index.show_tips('请完善您的个人信息')
				// 		setTimeout(()=>{
				// 			index.navigate_to('/pagesC/my/MyEditUserInfo');
				// 		},2000)
				// 	}else{
				// 		this.timestr = this.timestr==''?'上班时段':this.timestr
				// 		if(res.data.code == 500 && res.data.success == false){
				// 			index.show_tips(res.data.message)
				// 		}else{
				// 			this.telTips = true
				// 		}
				// 		return false
				// 	}
				// })
			}else{
				index.show_tips('系统跑小差了...')
				return false
			}
			

		}
  },
};
</script>
<style>
	.navBottom{
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		padding: 10rpx 20rpx;
		height: 100rpx;
		background: #f3F3F3;
		border-top: rgba(0, 0, 0, 0.2) solid 1px;
	}
	.navBottomList{
		/* display: flex;
		justify-content: space-between; */
		overflow: hidden;
	}
	.navBottomList view{
		float: left;
		text-align: center;
		font-size: 0;
	}
	.navBottomList view image{
		width: 48rpx;
		height: 48rpx;
		margin: 0;
		font-size: 0;
		margin-top: 10rpx;
	}
	.navBottomList view view{
		text-align: center;
		margin: 0;
		font-size: 28rpx;
		line-height: 60rpx;
		color: #3D3D3D;
		display: block;
		float: none;
		line-height: 40rpx;
	}
	.navBottomList view:nth-child(1){
		margin-right: 40rpx;
		width: 100rpx;
		text-align: center;
	}
	.navBottomList view:nth-child(4){
		width: 216rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin-top: 8rpx;
		margin-right: 16rpx;
		float: right;
		background: #FFA23F;
		border-radius: 6rpx;
		color: #fff;
	}
	.navBottomList view:nth-child(4) image{
		float: left;
		margin-left: 38rpx;
		margin-top: 20rpx;
		margin-right: 4rpx;
		width: 48rpx;
		height: 48rpx;
	}
	.navBottomList view:nth-child(4) view{
		float: left;
		color: #fff;
		line-height: 88rpx;
	}
	.navBottomList view:nth-child(3){
		width: 216rpx;
		height: 88rpx;
		line-height: 88rpx;
		margin-top: 8rpx;
		float: right;
		background: #0575FF;
		border-radius: 6rpx;
		color: #fff;
	}
	.navBottomList view:nth-child(3) image{
		float: left;
		margin-left: 38rpx;
		margin-top: 20rpx;
		margin-right: 4rpx;
		width: 48rpx;
		height: 48rpx;
	}
	.navBottomList view:nth-child(3) view{
		float: left;
		color: #fff;
		line-height: 88rpx;
	}
	.notCell view{ 
		font-size: 24rpx!important; 
		line-height: 40rpx!important; 
		margin-right: 0rpx!important; 
		width: 100%!important;
		text-align: center!important; 
		display: block!important; 
	}
	.telTips{ 
		padding: 32rpx 40rpx 20rpx 20rpx; text-align: center;
	}	
	.telTips image{
		width: 48rpx;
		height: 48rpx;
		margin-bottom: 16rpx;
	}
	.telTips view:nth-child(2){
		font-size: 36rpx!important;
		margin-bottom: 16rpx;
		font-weight: 500;
	}
	.telTips view:nth-child(3){
		font-size: 28rpx!important;
		font-weight: 100;
	}
	
	.sharec{
		padding: 0; border: 1px #F8F8F8 solid; font-size: 0rpx; color: #3D3D3D; width: 60rpx;
	}
	.sharec::after{border:none;}
</style>